<?php
class FileManager
{
    /**
     * The method generates a table of files uploaded to the server.
     * 
     * @return string - html code with generated table.
     */
    public function getFileList()
    {
        $fileList = array();
        if ( $query = DataBaseProvider::getFileList() )
        {
            $fileArray = DataBase::getInstance()->query( $query );
            if ( !empty( $fileArray ) )
            {
                $link = '/uploaded/';
                for ( $i = 0; $i < count( $fileArray ); $i++ )
                {
                    $fileList[] = array
                    (
                        'file_link' => $link . $fileArray[$i]['file_name'],
                        'file_name' => $fileArray[$i]['file_name'],
                        'user_id' => $fileArray[$i]['user_id'],
                        'file_raiting' => $fileArray[$i]['rating'],
                        'file_uploader' => $fileArray[$i]['first_name'] . ' ' . $fileArray[$i]['last_name']
                    );
                }
            }
        }
        return $fileList;
    }
}
?>